<template>
  <div id="water-chart">
    <div id="water-chart-top">
      <div class="water-level-chart-details">
        累计完成<span>{{ amount }}</span>元
      </div>
      <div class="chart-container">
        <dv-water-level-pond :config="config" />
      </div>
    </div>
    <cards />
  </div>
</template>

<script>
import {getAnnualSale} from '@/js/db'
import cards from './cards'

export default {
  name: 'WaterLevelChart',
  components: {
    cards
  },
  data () {
    return {
      target: null,
      amount: null,
      percentage: null,
      config: {}
    }
  },
  mounted() {
    getAnnualSale().then(response => {
      this.config = response.data.config
      this.amount = response.data.sale.amount

      //this.config.waveNum = 25
      //this.config.waveHeight = 25
      this.$error('年度销量未录入' + response.data.sale.error_date)
    })
    .catch(error => {
      console.log('数据获取失败:', error);
    });
  }
}
</script>

<style lang="less">
#water-chart {
  width: 40%;
}
#water-chart-top {
  box-sizing: border-box;
  margin-left: 20px;
  background-color: rgba(6, 30, 93, 0.5);
  border-top: 2px solid rgba(1, 153, 209, .5);
  display: flex;
  flex-direction: column;

  .water-level-chart-details {
    height: 15%;
    display: flex;
    justify-content: center;
    font-size: 17px;
    align-items: flex-end;

    span {
      font-size: 35px;
      font-weight: bold;
      color: #58a1ff;
      margin: 0 5px;
      margin-bottom: -5px;
    }
  }

  .chart-container {
    flex: 1;
    display: flex;
    margin-top: 10px;
    justify-content: center;
    align-items: center;
  }

  .dv-water-pond-level {
    max-width: 90%;
    width: 200px;
    height: 200px;
    border: 10px solid #19c3eb;
    border-radius: 50%;

    ellipse {
      stroke: transparent !important;
    }

    text {
      font-size: 40px;
    }
  }
}
</style>
